<script setup>
import * as IndustrialComplexService from '@/api/visual/industrialComplex'
import IntelligentIntegrationErp1 from './IntelligentIntegration-erp1.vue'
import IntelligentIntegrationErp2 from './IntelligentIntegration-erp2.vue'
import IntelligentIntegrationErp3 from './IntelligentIntegration-erp3.vue'
import IntelligentIntegrationErp4 from './IntelligentIntegration-erp4.vue'
import IntelligentIntegrationErp5 from './IntelligentIntegration-erp5.vue'
import IntelligentIntegrationErp6 from './IntelligentIntegration-erp6.vue'
import IntelligentIntegrationErp7 from './IntelligentIntegration-erp7.vue'

import IntelligentIntegrationErp8 from './IntelligentIntegration-erp8.vue'
import IntelligentIntegrationErp9 from './IntelligentIntegration-erp9.vue'

const pageData = ref({
  erp1: {
    config: {},
    key: 1
  },
  erp2: {
    config: {},
    key: 1
  },
  erp3: {
    config: {},
    key: 1
  },
  erp4: {
    config: {},
    key: 1
  },
  erp5: {
    config: {},
    key: 1
  },
  erp6: {
    config: {},
    key: 1
  },
  erp7: {
    config: {},
    key: 1
  },
  erp8: {
    config: {},
    key: 1
  },
  erp9: {
    config: {},
    key: 1
  }
})

const loadErp1 = async () => {
  const { data } = await IndustrialComplexService.loadIndustrialComplexErp1()
  const { config1, config2, config3 } = data

  pageData.value.erp1.config = config1

  pageData.value.erp2.config = config2
  pageData.value.erp3.config = config3
}

const loadErp2 = async () => {
  const { data } = await IndustrialComplexService.loadIndustrialComplexErp2()
  const { config1, config2, config3 } = data

  pageData.value.erp4.config = config1
  pageData.value.erp5.config = config2
  pageData.value.erp6.config = config3
}

const loadErp3 = async () => {
  const { data } = await IndustrialComplexService.loadIndustrialComplexErp3()
  const { config1= {}, config2 = {}, config3 = {} } = data

  pageData.value.erp7.config = config1
  pageData.value.erp8.config = config2
  pageData.value.erp9.config = config3
}

const loadData = async () => {
  Promise.all([loadErp1(), loadErp2(), loadErp3()])
}
onMounted(loadData)
</script>

<template>
  <div class="IntelligentIntegration2">
    <div class="dom1">
      <IntelligentIntegrationErp1 :options="pageData.erp1.config"></IntelligentIntegrationErp1>
    </div>
    <div class="dom2">
      <div>
        <IntelligentIntegrationErp7 :options="pageData.erp7.config"></IntelligentIntegrationErp7>
      </div>
      <div>
       <IntelligentIntegrationErp8 :options="pageData.erp8.config"></IntelligentIntegrationErp8>
      </div>
      <div>
        <IntelligentIntegrationErp9 :options="pageData.erp9.config"></IntelligentIntegrationErp9>
      </div>
    </div>
    <div class="dom3">
      <IntelligentIntegrationErp4 :options="pageData.erp4.config"></IntelligentIntegrationErp4>
    </div>
    <div class="dom4">
      <IntelligentIntegrationErp2 :options="pageData.erp2.config"></IntelligentIntegrationErp2>
    </div>
    <div class="dom5">
      <IntelligentIntegrationErp5 :options="pageData.erp5.config"></IntelligentIntegrationErp5>
    </div>
    <div class="dom6">
      <IntelligentIntegrationErp3 :options="pageData.erp3.config"></IntelligentIntegrationErp3>
    </div>
    <div class="dom7">
      <IntelligentIntegrationErp6 :options="pageData.erp6.config"></IntelligentIntegrationErp6>
    </div>
  </div>
</template>

<style lang="scss">
.IntelligentIntegration2 {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 10px;

  .dom2 {
    grid-column: 2 / 4;
    grid-row: 1/4;
    display: grid;
    grid-template-rows: 100px 1fr 1fr;
    gap: 10px;
  }
}
.dom-box {
  display: flex;
  flex-direction: column;
  height: 100%;

  .dom-title {
    height: 40px;
    background-color: rgba(14, 58, 119, 0.6);
    color: #2ca7e2;
    line-height: 40px;
    padding-left: 20px;
  }

  .dom-content {
    flex: 1;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .chart-content {
    flex: 1;
    overflow: hidden;

    height: calc(100% - 70px);
  }
}

:deep(.my-box7.dv-border-box-7) {
  box-shadow: initial !important;
}
</style>
